/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Presentacion;

import ModeloLogicoSistema.AdministradorCliente;
import ModeloLogicoSistema.AdministradorOrden;
import ModeloLogicoSistema.Cliente;
import ModeloLogicoSistema.Orden;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.ListIterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;


/**
 *
 * @author debo
 */
public class Ventana extends javax.swing.JDialog {

    Integer cod;
    String fecha;
    String estado;
    
    private ArrayList<Orden> ordenes;
    private ArrayList<Orden> ordenesIngresadas;
    private ArrayList<Orden> ordenesPendientes;
    private ArrayList<Orden> ordenesRealizadas;
    private ArrayList<Orden> ordenesRealizadasAentregar;
    private ArrayList<Orden> ordenesAEntregarYaEntregadas ;
    private ArrayList<Orden> ordenesEntregadas;
    private AdministradorOrden admOrdenes;
    private AdministradorCliente admCliente;
    private Orden orden;
    private SimpleDateFormat formateador = new SimpleDateFormat("dd/MM/yyyy");
    ModificacionOrden modOrden;
    
    public void cargarTablas(){
       
        this.cargarTablaOrdenesAentregarYaEntregadas(fecha);
        this.cargarTablaOrdenesEntregadas(fecha);
        this.cargarTablaOrdenesIngresadas(fecha);
        this.cargarTablaOrdenesPendientes(fecha);
        this.cargarTablaOrdenesRealizadas(fecha);
        this.cargarTablaOrdenesRealizadasAentregar(fecha);
    }
    
    public void ordenarTablas(){
       
            DefaultTableModel modelo=(DefaultTableModel)this.TablaEntregadas.getModel();
            TableRowSorter<TableModel> elQueOrdena = new TableRowSorter<TableModel>(modelo);
            this.TablaEntregadas.setRowSorter(elQueOrdena);
            
            modelo=(DefaultTableModel)this.TablaIngresadas.getModel();
            elQueOrdena = new TableRowSorter<TableModel>(modelo);
            this.TablaIngresadas.setRowSorter(elQueOrdena);
            
            modelo=(DefaultTableModel)this.TablaPendientes.getModel();
            elQueOrdena = new TableRowSorter<TableModel>(modelo);
            this.TablaPendientes.setRowSorter(elQueOrdena);
            
            modelo=(DefaultTableModel)this.TablaRealizadas.getModel();
            elQueOrdena = new TableRowSorter<TableModel>(modelo);
            this.TablaRealizadas.setRowSorter(elQueOrdena);
            
            modelo=(DefaultTableModel)this.tablaAentregar.getModel();
            elQueOrdena = new TableRowSorter<TableModel>(modelo);
            this.tablaAentregar.setRowSorter(elQueOrdena);
            
            modelo=(DefaultTableModel)this.tablaRealizadasAentregar.getModel();
            elQueOrdena = new TableRowSorter<TableModel>(modelo);
            this.tablaRealizadasAentregar.setRowSorter(elQueOrdena);
    }
    
    public void cargarTablaOrdenesIngresadas(String fecha) {
        DefaultTableModel modeloTabla = (DefaultTableModel) this.TablaIngresadas.getModel();
        int cantFilas = modeloTabla.getRowCount();
        for (int i = 0; i < cantFilas; i++) {
            modeloTabla.removeRow(0);
        }
        
        Collections.sort(ordenesIngresadas);
 
        for(Orden orden: ordenesIngresadas) {
            try {
                
                int cant=this.admOrdenes.getCantValetsPendientesXorden(orden.getCodOrden());
                int cantP=this.admOrdenes.getCantPlanchadosPendientesXorden(orden.getCodOrden());
                int cod = orden.getCodCliente();
                Cliente cliente = this.admCliente.cargarCliente(cod);
                Object[] fila = {orden.getCodOrden(), cod, cliente.getNombre() + " " + cliente.getApellido(),
                    orden.getFechaEntregaPactada(), orden.getHoraPactadaDesde(), orden.getMontoTotal(), orden.getMontoAbonado(), orden.getMontoAdeudado(),
                    orden.tieneDelivery(), orden.getSituacionOrden(),cant,cantP};

                modeloTabla.addRow(fila);
            } catch (SQLException ex) {
                Logger.getLogger(Ventana.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    public void cargarTablaOrdenesPendientes(String fecha) {        
        Collections.sort(ordenesPendientes);
        DefaultTableModel modeloTabla = (DefaultTableModel) this.TablaPendientes.getModel();
        int cantFilas = modeloTabla.getRowCount();
        for (int i = 0; i < cantFilas; i++) {
            modeloTabla.removeRow(0);
        }
        
        for (Orden orden: this.ordenesPendientes) {
            try {
                int cantV=this.admOrdenes.getCantValetsPendientesXorden(orden.getCodOrden());
                int cantP=this.admOrdenes.getCantPlanchadosPendientesXorden(orden.getCodOrden());
                int cod = orden.getCodCliente();
                Cliente cliente = this.admCliente.cargarCliente(cod);
                Object[] fila = {orden.getCodOrden(), cod, cliente.getNombre() + " " + cliente.getApellido(),
                    orden.getFechaEntregaPactada(), orden.getHoraPactadaDesde(), orden.getMontoTotal(), orden.getMontoAbonado(), orden.getMontoAdeudado(),
                    orden.tieneDelivery(), orden.getSituacionOrden(),cantV,cantP};

                modeloTabla.addRow(fila);
            } catch (SQLException ex) {
                Logger.getLogger(Ventana.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    public void cargarTablaOrdenesRealizadasAentregar(String fecha) {
        
        Collections.sort(ordenesPendientes);
        DefaultTableModel modeloTabla = (DefaultTableModel) this.tablaRealizadasAentregar.getModel();
        int cantFilas = modeloTabla.getRowCount();
        for (int i = 0; i < cantFilas; i++) {
            modeloTabla.removeRow(0);
        }
        
        ListIterator it = ordenesRealizadasAentregar.listIterator();
        while (it.hasNext()) {
             Orden orden = (Orden) it.next();
            int cod = orden.getCodCliente();
            Cliente cliente = this.admCliente.cargarCliente(cod);
            Object[] fila = {orden.getCodOrden(), cod, cliente.getNombre() + " " + cliente.getApellido(),
                orden.getFechaEntregaPactada(), orden.getHoraPactadaDesde(), orden.getMontoTotal(), orden.getMontoAbonado(), orden.getMontoAdeudado(),
                orden.tieneDelivery(), orden.getSituacionOrden()};

            modeloTabla.addRow(fila);
        }
    }
    
    public void cargarTablaOrdenesAentregarYaEntregadas(String fecha) { 
        try {
            Collections.sort(ordenesAEntregarYaEntregadas);
            DefaultTableModel modeloTabla = (DefaultTableModel) this.tablaAentregar.getModel();
            int cantFilas = modeloTabla.getRowCount();
            for (int i = 0; i < cantFilas; i++) {
                modeloTabla.removeRow(0);
            }
            
            for (Orden orden:this.ordenesAEntregarYaEntregadas) {
                int cod = orden.getCodCliente();
                Cliente cliente = this.admCliente.cargarCliente(cod);
                Object[] fila = {orden.getCodOrden(), cod, cliente.getNombre() + " " + cliente.getApellido(),
                    orden.getFechaEntregaPactada(), orden.getHoraPactadaDesde(), orden.getMontoTotal(), orden.getMontoAbonado(), orden.getMontoAdeudado(),
                    orden.tieneDelivery(), orden.getSituacionOrden()};

                modeloTabla.addRow(fila);
            }
        } catch (Exception ex) {
            Logger.getLogger(Ventana.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    public void cargarTablaOrdenesRealizadas(String fecha) {
        Collections.sort(ordenesRealizadas);
        DefaultTableModel modeloTabla = (DefaultTableModel) this.TablaRealizadas.getModel();
        int cantFilas = modeloTabla.getRowCount();
        for (int i = 0; i < cantFilas; i++) {
            modeloTabla.removeRow(0);
        }

        ListIterator it = ordenesRealizadas.listIterator();
        while (it.hasNext()) {
            Orden orden = (Orden) it.next();
            int cod = orden.getCodCliente();
            Cliente cliente = this.admCliente.cargarCliente(cod);
            Object[] fila = {orden.getCodOrden(), cod, cliente.getNombre() + " " + cliente.getApellido(),
                orden.getFechaEntregaPactada(), orden.getHoraPactadaDesde(), orden.getMontoTotal(), orden.getMontoAbonado(), orden.getMontoAdeudado(),
                orden.tieneDelivery(), orden.getSituacionOrden()};

            modeloTabla.addRow(fila);
        }
    }

    public void cargarTablaOrdenesEntregadas(String fecha) {
        
        Collections.sort(this.ordenesEntregadas);
        DefaultTableModel modeloTabla = (DefaultTableModel) this.TablaEntregadas.getModel();
        int cantFilas = modeloTabla.getRowCount();
        for (int i = 0; i < cantFilas; i++) {
            modeloTabla.removeRow(0);
        }

        ListIterator it = ordenesEntregadas.listIterator();
        while (it.hasNext()) {
            Orden orden = (Orden) it.next();
            int cod = orden.getCodCliente();
            Cliente cliente = this.admCliente.cargarCliente(cod);
            Object[] fila = {orden.getCodOrden(), cod, cliente.getNombre() + " " + cliente.getApellido(),
                orden.getFechaEntregaPactada(), orden.getHoraPactadaDesde(), orden.getMontoTotal(), orden.getMontoAbonado(), orden.getMontoAdeudado(),
                orden.tieneDelivery(), orden.getSituacionOrden()};

            modeloTabla.addRow(fila);
        }
    }

    public void cargarListasOrdenes() throws SQLException{
        this.ordenesPendientes = new ArrayList<>();
            this.ordenesRealizadas = new ArrayList<>();
            this.ordenesEntregadas = new ArrayList<>();
            this.ordenesIngresadas = new ArrayList<>();
            this.ordenesAEntregarYaEntregadas= new ArrayList<>();
            this.ordenesRealizadasAentregar= new ArrayList<>();
            this.ordenes = new ArrayList<>();
            this.admOrdenes = new AdministradorOrden();
            admCliente = new AdministradorCliente();
            cod = admOrdenes.nuevoCodigoOrden();
            orden = new Orden(cod);
            estado = orden.getSituacionOrden();

            this.ordenesEntregadas = (ArrayList<Orden>) this.admOrdenes.buscarOrdenesEntregadasElDia(fecha);            
            this.ordenesRealizadas = (ArrayList<Orden>) this.admOrdenes.buscarOrdenesRealizadasElDIA(fecha);
            ordenesRealizadasAentregar = (ArrayList<Orden>) this.admOrdenes.buscarOrdenesListasPautadasPara(fecha); 
            ordenesIngresadas = (ArrayList<Orden>) this.admOrdenes.buscarOrdenesCreadasElDIA(fecha);
            ordenesPendientes = (ArrayList<Orden>) this.admOrdenes.buscarOrdenesPendientesPautadasPara(fecha);
            this.ordenesAEntregarYaEntregadas=this.admOrdenes.buscarOrdenesEntregadasPautadasParaDia(fecha);
    }
    /**
     * Creates new form Ventana
     */
    public Ventana(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        try {
            
            
            initComponents();
            this.ordenarTablas();
            this.setLocationRelativeTo(null);
        } catch (Exception ex) {
            Logger.getLogger(Ventana.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void cargarFecha(String fecha){
        this.fecha=fecha;
        try {
            cargarListasOrdenes();
        } catch (SQLException ex) {
            Logger.getLogger(Ventana.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.cargarTablas();
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        OrdenesRealizadas = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        TablaPendientes = new javax.swing.JTable();
        jButton3 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tablaRealizadasAentregar = new javax.swing.JTable();
        jButton2 = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tablaAentregar = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        TablaIngresadas = new javax.swing.JTable();
        jButton6 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        TablaRealizadas = new javax.swing.JTable();
        jButton5 = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        TablaEntregadas = new javax.swing.JTable();
        jButton4 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel2.setMaximumSize(new java.awt.Dimension(32767, 450));
        jPanel2.setRequestFocusEnabled(false);

        TablaPendientes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Orden", "NroC.", "Cliente", "Fecha Pautada", "Hora Pautada", "Monto", "Seña", "Saldo", "Delivery", "Estado", "Valets", "Planchado"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Boolean.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        TablaPendientes.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(TablaPendientes);
        TablaPendientes.getColumnModel().getColumn(0).setPreferredWidth(30);
        TablaPendientes.getColumnModel().getColumn(1).setPreferredWidth(30);
        TablaPendientes.getColumnModel().getColumn(5).setPreferredWidth(30);
        TablaPendientes.getColumnModel().getColumn(6).setPreferredWidth(30);
        TablaPendientes.getColumnModel().getColumn(7).setPreferredWidth(0);
        TablaPendientes.getColumnModel().getColumn(8).setPreferredWidth(30);
        TablaPendientes.getColumnModel().getColumn(9).setPreferredWidth(40);
        TablaPendientes.getColumnModel().getColumn(10).setPreferredWidth(30);
        TablaPendientes.getColumnModel().getColumn(11).setPreferredWidth(40);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Detalle.png"))); // NOI18N
        jButton3.setText("Detalle");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton3)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 910, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(28, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton3)
                .addContainerGap(140, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Pendientes", jPanel2);

        tablaRealizadasAentregar.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Orden", "NroC.", "Cliente", "Fecha Pautada", "Hora Pautada", "Monto", "Seña", "Saldo", "Delivery", "Estado"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Boolean.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(tablaRealizadasAentregar);
        tablaRealizadasAentregar.getColumnModel().getColumn(0).setPreferredWidth(30);
        tablaRealizadasAentregar.getColumnModel().getColumn(1).setPreferredWidth(30);
        tablaRealizadasAentregar.getColumnModel().getColumn(5).setPreferredWidth(30);
        tablaRealizadasAentregar.getColumnModel().getColumn(6).setPreferredWidth(30);
        tablaRealizadasAentregar.getColumnModel().getColumn(7).setPreferredWidth(30);
        tablaRealizadasAentregar.getColumnModel().getColumn(8).setPreferredWidth(30);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Detalle.png"))); // NOI18N
        jButton2.setText("Detalle");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton2)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 910, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton2)
                .addContainerGap(140, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Realizadas", jPanel4);

        tablaAentregar.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Orden", "NroC.", "Cliente", "Fecha Pautada", "Hora Pautada", "Monto", "Seña", "Saldo", "Delivery", "Estado"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Boolean.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaAentregar.getTableHeader().setReorderingAllowed(false);
        jScrollPane3.setViewportView(tablaAentregar);
        tablaAentregar.getColumnModel().getColumn(0).setPreferredWidth(30);
        tablaAentregar.getColumnModel().getColumn(1).setPreferredWidth(30);
        tablaAentregar.getColumnModel().getColumn(5).setPreferredWidth(30);
        tablaAentregar.getColumnModel().getColumn(6).setPreferredWidth(30);
        tablaAentregar.getColumnModel().getColumn(7).setPreferredWidth(30);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Detalle.png"))); // NOI18N
        jButton1.setText("Detalle");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton1)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 910, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(140, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Entregadas", jPanel8);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane2)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane2)
        );

        OrdenesRealizadas.addTab("Ordenes a Entregar ", jPanel3);

        TablaIngresadas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Orden", "NroC.", "Cliente", "Fecha Pautada/Entrega", "Hora Pautada/Entrega", "Monto", "Seña", "Saldo", "Delivery", "Estado", "Valets ", "Planchado"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Boolean.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        TablaIngresadas.getTableHeader().setReorderingAllowed(false);
        jScrollPane6.setViewportView(TablaIngresadas);
        TablaIngresadas.getColumnModel().getColumn(0).setPreferredWidth(50);
        TablaIngresadas.getColumnModel().getColumn(1).setPreferredWidth(50);

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Detalle.png"))); // NOI18N
        jButton6.setText("Detalle");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton6)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 910, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton6)
                .addContainerGap(152, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Ingresadas", jPanel1);

        TablaRealizadas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Orden", "NroC.", "Cliente", "Fecha Pautada/Entrega", "Hora Pautada/Entrega", "Monto", "Seña", "Saldo", "Delivery", "Estado"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Boolean.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        TablaRealizadas.getTableHeader().setReorderingAllowed(false);
        jScrollPane5.setViewportView(TablaRealizadas);

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Detalle.png"))); // NOI18N
        jButton5.setText("Detalle");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton5)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 910, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton5)
                .addContainerGap(152, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Realizadas", jPanel6);

        TablaEntregadas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Orden", "NroC.", "Cliente", "Fecha Pautada/Entrega", "Hora Pautada/Entrega", "Monto", "Seña", "Saldo", "Delivery", "Estado"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Boolean.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        TablaEntregadas.getTableHeader().setReorderingAllowed(false);
        jScrollPane4.setViewportView(TablaEntregadas);

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Detalle.png"))); // NOI18N
        jButton4.setText("Detalle");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton4)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 910, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton4)
                .addContainerGap(152, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Entregadas", jPanel7);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 556, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        OrdenesRealizadas.addTab("Ordenes que fueron...", jPanel5);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(OrdenesRealizadas, javax.swing.GroupLayout.PREFERRED_SIZE, 976, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(OrdenesRealizadas, javax.swing.GroupLayout.PREFERRED_SIZE, 572, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        int seleccion;
        Integer cod;
        try{
            seleccion=this.tablaRealizadasAentregar.getSelectedRow();
            cod= (Integer) this.tablaRealizadasAentregar.getValueAt(seleccion, 0);
            ModificacionOrden mod=new ModificacionOrden(null, rootPaneCheckingEnabled);
            mod.iniciarComponentes(cod);
            this.cargarListasOrdenes();
            this.cargarTablas();
        }catch (Exception e){
            JOptionPane.showMessageDialog(null, "Hubo un error y no se pudo cargar la orden seleccionada lo sentimos.", "Selección", JOptionPane.YES_OPTION);
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        int seleccion;
        Integer cod;
        try{
            seleccion=this.TablaIngresadas.getSelectedRow();
            cod= (Integer) this.TablaIngresadas.getValueAt(seleccion, 0);
            ModificacionOrden mod=new ModificacionOrden(null, rootPaneCheckingEnabled);
            mod.iniciarComponentes(cod);
            this.cargarListasOrdenes();
            this.cargarTablas();
        }catch (Exception e){
            JOptionPane.showMessageDialog(null, "Hubo un error y no se pudo cargar la orden seleccionada lo sentimos.", "Selección", JOptionPane.YES_OPTION);
        }
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        int seleccion;
        Integer cod;
        try{
            seleccion=this.TablaRealizadas.getSelectedRow();
            cod= (Integer) this.TablaRealizadas.getValueAt(seleccion, 0);
            ModificacionOrden mod=new ModificacionOrden(null, rootPaneCheckingEnabled);
            mod.iniciarComponentes(cod);
            this.cargarListasOrdenes();
            this.cargarTablas();
        }catch (Exception e){
            JOptionPane.showMessageDialog(null, "Hubo un error y no se pudo cargar la orden seleccionada lo sentimos.", "Selección", JOptionPane.YES_OPTION);
        }

    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        int seleccion;
        Integer cod;
        try{
            seleccion=this.TablaEntregadas.getSelectedRow();
            cod= (Integer) this.TablaEntregadas.getValueAt(seleccion, 0);
            ModificacionOrden mod=new ModificacionOrden(null, rootPaneCheckingEnabled);
            mod.iniciarComponentes(cod);
            this.cargarListasOrdenes();
            this.cargarTablas();
        }catch (Exception e){
            JOptionPane.showMessageDialog(null, "Hubo un error y no se pudo cargar la orden seleccionada lo sentimos.", "Selección", JOptionPane.YES_OPTION);
        }

    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        int seleccion;
        Integer cod;
        try{
            seleccion=this.TablaPendientes.getSelectedRow();
            cod= (Integer) this.TablaPendientes.getValueAt(seleccion, 0);
            ModificacionOrden mod=new ModificacionOrden(null, rootPaneCheckingEnabled);
            mod.iniciarComponentes(cod);
            this.cargarListasOrdenes();
            this.cargarTablas();
        }catch (Exception e){
            JOptionPane.showMessageDialog(null, "Hubo un error y no se pudo cargar la orden seleccionada lo sentimos.", "Selección", JOptionPane.YES_OPTION);
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        int seleccion;
        Integer cod;
        try{
            seleccion=this.tablaAentregar.getSelectedRow();
            cod= (Integer) this.tablaAentregar.getValueAt(seleccion, 0);
            ModificacionOrden mod=new ModificacionOrden(null, rootPaneCheckingEnabled);
            mod.iniciarComponentes(cod);
            this.cargarListasOrdenes();
            this.cargarTablas();
        }catch (Exception e){
            JOptionPane.showMessageDialog(null, "Hubo un error y no se pudo cargar la orden seleccionada lo sentimos.", "Selección", JOptionPane.YES_OPTION);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    
    
    //public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
/*        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
     /*   java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Ventana dialog = null;
                try {
                    dialog = new Ventana(new javax.swing.JFrame(), true);
                } catch (Exception ex) {
                    Logger.getLogger(Ventana.class.getName()).log(Level.SEVERE, null, ex);
                }
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }*/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane OrdenesRealizadas;
    private javax.swing.JTable TablaEntregadas;
    private javax.swing.JTable TablaIngresadas;
    private javax.swing.JTable TablaPendientes;
    private javax.swing.JTable TablaRealizadas;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTable tablaAentregar;
    private javax.swing.JTable tablaRealizadasAentregar;
    // End of variables declaration//GEN-END:variables
}
